package databases

import (
	"context"

	"ginchat/internal/globals/vipers"

	"github.com/go-redis/redis/v8"
)

var (
	redisClient *redis.Client
)

func InitRedisClient() error {
	v := vipers.GetDatabaseViper()
	
	redisClient = redis.NewClient(&redis.Options{
		Addr: v.GetString("redis.addr"),
		Password: v.GetString("redis.password"),
		DB: v.GetInt("redis.db"),
		PoolSize: v.GetInt("redis.poolSize"),
	})
	_, err := redisClient.Ping(context.Background()).Result()
	return err
}

func GetRedisClient() *redis.Client {
	return redisClient
}